//
//  MineViewBtn.m
//  AILock
//
//  Created by 谭亚明 on 2020/6/24.
//  Copyright © 2020 tym. All rights reserved.
//

#import "MineViewBtn.h"
#import "Masonry.h"
#import "Fonts.h"
#import "Colors.h"
#import "TYMLabel.h"
#import "UIButton+ImageTitleSpacing.h"
#import "TYMButton.h"
@interface MineViewBtn()

@property(nonatomic,weak) TYMButton  *image;
@property(nonatomic,weak) TYMLabel   *lable;
@end

@implementation MineViewBtn

-(void)awakeFromNib{
    [super awakeFromNib];

    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(15,122,115,102);
    gl.startPoint = CGPointMake(0.5, 0);
    gl.endPoint = CGPointMake(0.5, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:229/255.0 green:241/255.0 blue:255/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:254/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor];
    gl.locations = @[@(0), @(1.0f)];
    self.layer.shadowColor = [UIColor colorWithRed:250/255.0 green:251/255.0 blue:255/255.0 alpha:1.0].CGColor;
    self.layer.shadowOffset = CGSizeMake(0,7.5);
    self.layer.shadowOpacity = 1;
    self.layer.shadowRadius = 15;
    
    TYMButton  *imag = [TYMButton btn_text:@"" image:@"icon_mine333" color:[UIColor redColor] font:Font_Medium(15)];
    [imag addTarget:self action:@selector(tapAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:imag];
    [imag mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(82, 82));
    }];
    self.image = imag;
    
    TYMLabel *lab = [TYMLabel lb_text:@"" font:Font_Regular(12) color:rgba(74, 74, 74)];
    lab.textAlignment = NSTextAlignmentCenter;
    [self addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self.image.mas_bottom).offset(-9);
    }];
    self.lable = lab;
}

-(void)tapAction:(id)sender{
    if (self.tapMineViewBtnBlock) {
        self.tapMineViewBtnBlock();
    }
}

-(void)setImageName:(NSString*)imageName title:(NSString*)title{
    
    self.lable.text = title;
    [self.image setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [self.image setImage:[UIImage imageNamed:imageName] forState:UIControlStateSelected];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
